package cn.edu.cxcyzx.conf;

public enum Role {
	ADMIN(0,"admin"),ADMIN_STU(1,"admin_stu")
	,STU(2,"student"),TEA(3,"teacher");
	private int id;
	private String name;
	private Role(int id,String name) {
		this.id=id;
		this.name=name;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return "id:"+id+",name:"+name;
	}
	public static Role getById(int id){
		for(Role role:Role.values()){
			if(role.getId()==id){
				return role;
			}
		}
		return null;
	}
	public static Role getByName(String name){
		for(Role role:Role.values()){
			if(role.getName().equals(name)){
				return role;
			}
		}
		return null;
	}

}
